﻿Imports JosSDK

Public Class Form1

    Public Const Url As String = "http://auth.360buy.com/oauth/token?grant_type=authorization_code&client_id={0}&client_secret={1}&scope=read&redirect_uri=http://{2}&code={3}&state=1234"

    Public Const Url2 As String = "http://auth.360buy.com/oauth/authorize?response_type=code&client_id={0}&redirect_uri={1}&state={2}"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim access_token = "463b5934-0a26-428c-9f89-db49d01cccb3"
        Dim app_key = "759211B4FEBD99CD7C40A4013565D570"
        Dim app_secret = "f3136d11540c464682536f0cf6ef31b3"

        Dim client As New DefaultJosClient("http://gw.api.sandbox.360buy.com/routerjson", access_token, app_key, app_secret)

        Dim req As New OrderSearchRequest

        req.EndDate = "2012-05-16 17:03:56"
        req.OptionalFields = "vender_id,order_id,pay_type,order_total_price,freight_price, seller_discount,order_payment,delivery_type,order_state,order_state_remark,invoice_info,order_remark,order_start_time,order_end_time, consignee_info,item_info_list"
        req.OrderState = "WAIT_SELLER_STOCK_OUT"
        req.Page = 1
        req.PageSize = 200
        req.StartDate = "2012-05-14 17:03:56"

        Dim res = client.Execute(req)
        Clipboard.SetText(GetToken())

    End Sub

    Function GetToken()
        'Dim access_token = "463b5934-0a26-428c-9f89-db49d01cccb3"
        Dim app_key = "759211B4FEBD99CD7C40A4013565D570"
        Dim app_secret = "f3136d11540c464682536f0cf6ef31b3"
        Dim uri As String = String.Format(Url, app_key, app_secret, "www.360buy.com", "code")
        'uri = String.Format(Url2, app_key, "http://www.360buy.com", "1234")
        Return uri
    End Function

End Class
